<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List" %>
<%@page import="java.util.Map" %>
<%@page import="java.util.Iterator" %>
<%@page import="java.math.BigDecimal" %>
<%@page import="java.text.DecimalFormat" %>
<%@include file="headProd.jsp" %>

<div class="pagines">
    <% for(int i = 1; i <= (Integer)request.getAttribute("numPagines"); i++) { %>
    <span><%=i %></span>
    <% } %>
</div>
<div id="page">
<%
List<Map<String,Object>> llistat = (List<Map<String,Object>>) request.getAttribute("productes");
Iterator<Map<String,Object>> it = llistat.iterator();
Map<String,Object> id;

while(it.hasNext()) {
    id = it.next();
    DecimalFormat formatter = new DecimalFormat("#####0.00");
    %>
    <div class="producte">
        <div class="img"><img alt="pepitu" src="productes?id=<%=id.get("id_prod") %>&op=2" value="<%=id.get("id_prod") %>"/></div>
        <div class="nomProd"><span  value="<%=id.get("id_prod") %>"><%=id.get("nom") %></span></div>
        <div class="flags">
            <% if (((BigDecimal)id.get("stock")).intValue() > 0) { %>
            <img src="imatges/in-stock.gif" />
            <%}%>
            <span class="preu"><%=formatter.format(id.get("preu")) %>&euro;</span>
        </div>
        <div class="addcar">
            <form method="post" action="usuaris">
                <input type="hidden" value="4" name="op" />
                <input type="hidden" value="<%=id.get("id_prod") %>" name="id" />
                <input type="submit" class="boto" value="Afegeix" />
                <input type="text" name="num" value="1" maxlength="4"/>
            </form>
        </div>
    </div>
<% } %>
</div>
<div class="paginesB">
    <% for(int i = 1; i <= (Integer)request.getAttribute("numPagines"); i++) { %>
    <span><%=i %></span>
    <% } %>
</div>